package http

import (
	"net/http"

	"github.com/gin-gonic/gin"
	"org.knight/biz/repo"
	"org.knight/data"
)

type IEHttpHandler struct {
	Repo *repo.DBRepository
}

// @Summary info element query interface
// @Description information element query
// @Tags query
// @Accept plain
// @Produce json
// @Param key path   string true "infom element"
// @Router /infoElement/{key} [get]
func (h IEHttpHandler) Handle(c *gin.Context) {

	k := c.Param("key")
	var ieArray []data.InfoElement

	h.Repo.DB().Model(&data.InfoElement{}).Where("name like ?", k+"%").Find(&ieArray)

	//
	c.JSON(http.StatusOK, ieArray)

}
